﻿using System;
using UnityEngine;

// Token: 0x0200057D RID: 1405
public class EyeLookMaterialControll : MonoBehaviour
{
	// Token: 0x060021C7 RID: 8647 RVA: 0x001323D0 File Offset: 0x001305D0
	public virtual void Start()
	{
		this._material = base.GetComponent<Renderer>().material;
		Texture mainTexture = this._material.mainTexture;
		this.textureWidth = mainTexture.width;
		this.textureHeight = mainTexture.height;
		float num = 0f;
		this.rect.y = num;
		this.rect.x = num;
		this.rect.width = (float)this.textureWidth;
		this.rect.height = (float)this.textureHeight;
		this.offset = default(Vector2);
		this.scale = default(Vector2);
		global::Debug.Log(this.textureWidth + "/" + this.textureHeight);
	}

	// Token: 0x060021C8 RID: 8648 RVA: 0x00132498 File Offset: 0x00130698
	public virtual void Update()
	{
		this.rect.x = Mathf.Lerp((float)this.InsideWait, (float)this.OutsideWait, Mathf.InverseLerp(-1f, 1f, this.script.GetAngleHRate(this.eyeLR)));
		this.rect.y = Mathf.Lerp((float)this.DownWait, (float)this.UpWait, Mathf.InverseLerp(-1f, 1f, this.script.GetAngleVRate()));
		this.offset = new Vector2(Mathf.Clamp(this.rect.x / (float)this.textureWidth, this.InsideLimit, this.OutsideLimit), Mathf.Clamp(this.rect.y / (float)this.textureHeight, this.UpLimit, this.DownLimit));
		this.scale = new Vector2(this.rect.width / (float)this.textureWidth, this.rect.height / (float)this.textureHeight);
		this._material.SetTextureOffset("_MainTex", this.offset);
		this._material.SetTextureScale("_MainTex", this.scale);
	}

	// Token: 0x060021C9 RID: 8649 RVA: 0x001325CC File Offset: 0x001307CC
	public virtual Vector2 GetEyeTexOffset()
	{
		return this.offset;
	}

	// Token: 0x060021CA RID: 8650 RVA: 0x001325D4 File Offset: 0x001307D4
	public virtual Vector2 GetEyeTexScale()
	{
		return this.scale;
	}

	// Token: 0x040029FB RID: 10747
	public global::EyeLookCalc script;

	// Token: 0x040029FC RID: 10748
	public int InsideWait;

	// Token: 0x040029FD RID: 10749
	public int OutsideWait;

	// Token: 0x040029FE RID: 10750
	public int UpWait;

	// Token: 0x040029FF RID: 10751
	public int DownWait;

	// Token: 0x04002A00 RID: 10752
	public float InsideLimit;

	// Token: 0x04002A01 RID: 10753
	public float OutsideLimit;

	// Token: 0x04002A02 RID: 10754
	public float UpLimit;

	// Token: 0x04002A03 RID: 10755
	public float DownLimit;

	// Token: 0x04002A04 RID: 10756
	public global::EYE_LR eyeLR;

	// Token: 0x04002A05 RID: 10757
	public Rect Limit;

	// Token: 0x04002A06 RID: 10758
	public Rect rect;

	// Token: 0x04002A07 RID: 10759
	protected Material _material;

	// Token: 0x04002A08 RID: 10760
	protected int textureWidth;

	// Token: 0x04002A09 RID: 10761
	protected int textureHeight;

	// Token: 0x04002A0A RID: 10762
	protected Vector2 offset;

	// Token: 0x04002A0B RID: 10763
	protected Vector2 scale;
}
